# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -mtriple=aarch64-apple-ios -run-pass=legalizer -verify-machineinstrs %s -o - | FileCheck %s

# Check that we can legalize G_BZERO on Darwin.

...
---
name:            bzero
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $x0, $x1
    ; CHECK-LABEL: name: bzero
    ; CHECK: liveins: $x0, $x1
    ; CHECK: %ptr:_(p0) = COPY $x0
    ; CHECK: %width:_(s64) = COPY $x1
    ; CHECK: ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
    ; CHECK: $x0 = COPY %ptr(p0)
    ; CHECK: $x1 = COPY %width(s64)
    ; CHECK: BL &bzero, csr_darwin_aarch64_aapcs, implicit-def $lr, implicit $sp, implicit $x0, implicit $x1
    ; CHECK: ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
    ; CHECK: RET_ReallyLR
    %ptr:_(p0) = COPY $x0
    %width:_(s64) = COPY $x1
    G_BZERO %ptr(p0), %width(s64), 0 :: (store (s32))
    RET_ReallyLR

...
---
name:            bzero_tail_call
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $x0, $x1
    ; CHECK-LABEL: name: bzero_tail_call
    ; CHECK: liveins: $x0, $x1
    ; CHECK: %ptr:_(p0) = COPY $x0
    ; CHECK: %width:_(s64) = COPY $x1
    ; CHECK: $x0 = COPY %ptr(p0)
    ; CHECK: $x1 = COPY %width(s64)
    ; CHECK: TCRETURNdi &bzero, 0, csr_darwin_aarch64_aapcs, implicit $sp, implicit $x0, implicit $x1
    %ptr:_(p0) = COPY $x0
    %width:_(s64) = COPY $x1
    G_BZERO %ptr(p0), %width(s64), 1 :: (store (s32))
    RET_ReallyLR
